package fr.mywiki.business.utils;

import java.text.DateFormat;
import java.text.ParseException;
import java.util.Date;

public class DateUtils {
	/**
	 * Formats the given date into a better format.
	 * 
	 * @param date
	 *          a <code>Date</code> object.
	 * @return a <code>String</code> representation of the date.
	 */
	public static String formatDate(Date date) {
		DateFormat df = DateFormat.getInstance();
		
		return df.format(date);
	}
	
	/**
	 * Parses the entered string into a correct date.
	 * 
	 * @param date
	 *          a <code>String</code> object.
	 * @return a <code>Date</code> object.
	 * @throws ParseException
	 *           if the entered string does not correspond to a valid date.
	 */
	public static Date parseDate(String date) throws ParseException {
		DateFormat df = DateFormat.getDateInstance();
		
		return df.parse(date);
	}
}
